import React from 'react'
import { useRef } from 'react'

export default function UseRefCom() {

  //1. 创建 ref 容器
  let input = useRef(); // createRef();
  let result = useRef();

  //声明函数
  let show = () => {
    //3. 获取真实 DOM
    let v = input.current.value;
    //设置
    result.current.innerHTML = v;
  }

  return (
    <div>
      {/* 2. 设置 ref 属性 */}
      <input type="text" ref={input} /><button onClick={show}>显示</button>
      <hr />
      <div ref={result} id="result" style={{width: 400, height: 300, border: 'solid 1px #abc'}}></div>
    </div>
  )
}
